#version 440

layout(binding = 2) uniform sampler2D texTiles[30];

in block
{
	//in vec4 Position;
	vec4 Color;
	vec2 Texcoord1;
	vec2 Texcoord2;
	flat int texIndex1;
	flat int texIndex2;
};

layout(location=0) out vec3 FragColor;
layout(location=1) out vec4 FragColor2;

void main()
{
	if (texIndex2==255)
	{
		//FragColor=Color.rgb;
		FragColor=texture2D(texTiles[texIndex1],Texcoord1).rgb * Color.rgb;
	}
	else
	{
		vec3 clr1=texture2D(texTiles[texIndex1],Texcoord1).rgb;
		vec3 clr2=texture2D(texTiles[texIndex2],Texcoord2).rgb;
		vec3 clr3=(1-Color.a) * Color.rgb * clr1 + Color.a * Color.rgb * clr2;
		FragColor=clamp(clr3,0,1);
	}
	//FragColor=vec3(1.0);
	FragColor2=vec4(203/255.0, 143/255.0, 243/255.0, 243/255.0);
	//FragColor2=vec4(1.0);
}